const { join, resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: "development",
    output: {
        assetModuleFilename: "images/[name][ext]",
        filename: "scripts/[name].bundle.js"
    },
    devServer: {
        historyApiFallback: true,
        static: {
            directory: join(__dirname, '../dist'),
        },
        proxy: {
            '/api': {
              target: 'http://localhost:3002',
              pathRewrite: { '^/api': '' },
            },
          },
        compress: true,
        open: true,
        port: 3000,
    },
    devtool: "source-map",
    plugins: [
        new HtmlWebpackPlugin({
            title: "智慧怀化",
            filename: "index.html",
            template: resolve(__dirname, "../src/index-dev.html")
        })
    ]
}